#include <d3d9.h>
#include <d3dx9.h>
#include "Game.h"
#include "Textures.h"
#include "BufferCollection.h"
#include "World.h"
#include "Camera.h"
#include "time.h"

Minicraft::BufferCollection* Minicraft::BufferCollectionInstance;
Minicraft::World* Minicraft::testWorld;
Minicraft::Camera::GameCamera* Minicraft::camera;

// Contains game-specific initialization code.
void Minicraft::Initalize(LPDIRECT3DDEVICE9 device)
{
	// seed the random number generator
	srand((unsigned)time(NULL));

	// create our initial BufferCollection
	Minicraft::BufferCollectionInstance = new Minicraft::BufferCollection(device);

	// Load our textures
	Minicraft::Textures::LoadTextures();

	// create our world
	Minicraft::testWorld = new Minicraft::World();

	// create our camera
	Minicraft::camera = new Minicraft::Camera::GameCamera(device);
	Minicraft::camera->GetCameraPosition()->x = 0.0f;
	Minicraft::camera->GetCameraPosition()->y = 25.0f;
	Minicraft::camera->GetCameraPosition()->z = 35.0f;
	Minicraft::camera->GetLookPosition()->x = 0.0f;
	Minicraft::camera->GetLookPosition()->y = 25.0f;
	Minicraft::camera->GetLookPosition()->z = 25.0f;

	Minicraft::testWorld->theWorld[0][0][0]->SetType(Minicraft::CubeType::Air);
}

// Contains game-specific cleanup code.
void Minicraft::Dispose()
{
	delete testWorld;

	// Unload our textures
	Minicraft::Textures::UnloadTextures();

	delete BufferCollectionInstance;
}